package com.wuye.action;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wuye.entity.Tousu;
import com.wuye.service.TousuService;

@Controller
@RequestMapping("/tousu")
public class TousuAction {
	@Resource
	private TousuService tousuService;
	//增加
	@RequestMapping("/save")
	public String save(Tousu tousu,HttpServletRequest request){
		tousuService.save(tousu);
		request.setAttribute("msg", "已投诉");
		return "../sqts.jsp";
	}
	//删除
	@RequestMapping("/del")
	public String del(String str,HttpServletRequest request){
		tousuService.del(str);
		request.setAttribute("msg", "已删除");
		return "../ts.jsp";
	}
	//更新
	@RequestMapping("/update")
		public String update(String str,HttpServletRequest request){
			tousuService.update(str);
			request.setAttribute("msg", "已处理");
			return "../ts.jsp";
		}
	//列表
	@RequestMapping("/allList")
	public @ResponseBody Map getAllList(String page,String rows,HttpServletRequest request){
		int intPage = Integer.parseInt((page == null || page =="0") ? "1":page); 
        int number = Integer.parseInt((rows == null || rows =="0") ? "10":rows); 
        int start = (intPage-1)*number; 
        return tousuService.getList(start,number);
	}
	//查询
	@RequestMapping("/searchList")
	public @ResponseBody Map getSearchList(Tousu tousu,String page,String rows,HttpServletRequest request) throws Exception{
		int intPage = Integer.parseInt((page == null || page =="0") ? "1":page); 
        int number = Integer.parseInt((rows == null || rows =="0") ? "10":rows); 
        int start = (intPage-1)*number; 
        return tousuService.getSearchList(tousu,start,number);
	}
	public TousuService getTousuService() {
		return tousuService;
	}
	public void setTousuService(TousuService tousuService) {
		this.tousuService = tousuService;
	}
}
